package com.slofzx.nuoda.evaluation.version.controller;

import com.slofzx.nuoda.common.annotation.SysLog;
import com.slofzx.nuoda.common.controller.BaseController;
import com.slofzx.nuoda.common.enums.CommonResultEnum;
import com.slofzx.nuoda.common.enums.ServiceResult;
import com.slofzx.nuoda.common.util.DataConvertUtil;
import com.slofzx.nuoda.common.vo.AjaxResultVO;
import com.slofzx.nuoda.common.vo.FileVO;
import com.slofzx.nuoda.common.vo.PageResultVO;
import com.slofzx.nuoda.evaluation.compute.data.service.ComputeDetailDataService;
import com.slofzx.nuoda.evaluation.core.util.StringUtil;
import com.slofzx.nuoda.evaluation.dto.MonteCarloItemDTO;
import com.slofzx.nuoda.evaluation.project.observer.BatchObserver;
import com.slofzx.nuoda.evaluation.version.dto.BatchComputeDTO;
import com.slofzx.nuoda.evaluation.version.dto.ComputeVersionDTO;
import com.slofzx.nuoda.evaluation.version.service.BatchComputeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 评价信息控制层
 *
 * @author nuoda
 * @menu 评价信息
 * @since 2021-11-19 15:56:07
 */
@RestController
@RequestMapping("/compute_version/batch")
public class BatchComputeController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private BatchComputeService batchComputeService;


    /**
     * 创建版本并自动计算
     *
     * @param dto 参数数据
     * @return 操作结果
     */
    @SysLog(title = "任务批量计算")
    @ResponseBody
    @PostMapping(value = "/invoke")
    public AjaxResultVO batchCompute(@RequestBody BatchComputeDTO dto) {
        ServiceResult resultEnum = batchComputeService.computeBatchResult(dto);
        if(resultEnum == CommonResultEnum.SUCCESS) {
            return AjaxResultVO.newSuccessResult(dto.getId());
        }
        return AjaxResultVO.getInstance(resultEnum);
    }

}
